<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <counter :count="0" @inc="handleInc"></counter>
        <counter :count="1" @inc="handleInc"></counter>
        <div>{{total}}</div>
    </div>
    <script>
        let counter = {
            props: ["count"],
            data: function(){
              return {
                  number: this.count
              }
            },
            template: "<div @click='handleClick'>{{number}}</div>",
            methods: {
                handleClick: function () {
                    this.number ++;
                    this.$emit('inc', 1)
                }
            }
        }
        let vm = new Vue({
            el:"#app",
            components: {
              counter: counter
            },
            data: {
                total: 1
            },
            methods: {
                handleInc: function (step) {
                    console.log(step);
                    this.total += step;
                }
            }
        })
    </script>
</body>
</html>
